package org.linlinjava.litemall.admin.web2.goods.resp;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.linlinjava.litemall.core.util.DateTimeUtil;
import org.linlinjava.litemall.core.util.Util;
import org.linlinjava.litemall.db.domain.TGoods;
import org.linlinjava.litemall.db.enumeration.Const;
import org.linlinjava.litemall.db.util.Str;

import java.time.LocalDateTime;

@ApiModel
public class GResp2 {

    @ApiModelProperty("id")
    private Integer id;
    @ApiModelProperty("名称")
    private String name;
    @ApiModelProperty("图片")
    private String img;
    @ApiModelProperty("分类")
    private String catalog;
    @ApiModelProperty("折扣")
    private Double discount;
    @ApiModelProperty("当前价")
    private Double currentPrice;
    @ApiModelProperty("销售价")
    private Double salePrice;
    @ApiModelProperty("成本价")
    private Double costPrice;
    @ApiModelProperty("佣金")
    private Integer commission;
    @ApiModelProperty("每日库存")
    private Integer dailyNum;
    @ApiModelProperty("开售时间")
    private String saleTime;
    @ApiModelProperty("状态")
    private String statusStr;


    public GResp2(TGoods goods) {
        this.id = goods.getId();
        this.name = goods.getMainTitle();
        costPrice = goods.getCostPrice().doubleValue();
        currentPrice = goods.getCurrentPrice().doubleValue();
        salePrice = goods.getSalePrice().doubleValue();
        this.discount = Util.retain2(currentPrice / salePrice);
        dailyNum = goods.getDailyLimit();
        if (goods.getSaleTime() != null)
            saleTime = goods.getSaleTime().format(DateTimeUtil.format);
        commission = 10;
        statusStr = Const.GOODS_STATUS.value(goods.getStatus());

        catalog = "分类";
        img = goods.getMainPic();
    }

    public GResp2() {
    }

    public String getImg() {
        return img;
    }

    public void setImg(String img) {
        this.img = img;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getStatusStr() {
        return statusStr;
    }

    public void setStatusStr(String statusStr) {
        this.statusStr = statusStr;
    }

    public String getCatalog() {
        return catalog;
    }

    public void setCatalog(String catalog) {
        this.catalog = catalog;
        if (Str.isEmpty(catalog))
            this.catalog = catalog;
    }

    public Double getDiscount() {
        return discount;
    }

    public void setDiscount(Double discount) {
        this.discount = discount;
    }

    public Double getCurrentPrice() {
        return currentPrice;
    }

    public void setCurrentPrice(Double currentPrice) {
        this.currentPrice = currentPrice;
    }

    public Double getSalePrice() {
        return salePrice;
    }

    public void setSalePrice(Double salePrice) {
        this.salePrice = salePrice;
    }

    public Double getCostPrice() {
        return costPrice;
    }

    public void setCostPrice(Double costPrice) {
        this.costPrice = costPrice;
    }

    public Integer getCommission() {
        return commission;
    }

    public void setCommission(Integer commission) {
        this.commission = commission;
    }

    public Integer getDailyNum() {
        return dailyNum;
    }

    public void setDailyNum(Integer dailyNum) {
        this.dailyNum = dailyNum;
    }

    public String getSaleTime() {
        return saleTime;
    }

    public void setSaleTime(String saleTime) {
        this.saleTime = saleTime;
    }
}
